﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Demo02
{
    public partial class FrmGoodsList : Form
    {
        public FrmGoodsList()
        {
            InitializeComponent();
            LoadData();
        }

        private void LoadData()
        {
            foreach (MyGoods record in FrmMain.GoodsList)
            {
                listBox1.Items.Add(string.Format("{0}{1}{2}{3}",
                    MotoCommon.MotoCommon.str2print(record.BarCode, 1),
                    MotoCommon.MotoCommon.str2print(record.GoodsName, 1),
                    MotoCommon.MotoCommon.str2print(record.GoodsAmount.ToString(), 2),
                    MotoCommon.MotoCommon.str2print(record.GoodsDate, 3)));
            }
        }

        private void FrmGoodsList_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == (char)120)
            {
                this.Close();
                return;
            }
            else if (e.KeyValue == (char)121)	// 按"F"+"F2"键
            {
                //显示数据列表
                MotoCommon.MotoReaderAction.turnOnBacklight();
            }
            else if (e.KeyValue == (char)114)	// 按"F"+"F2"键
            {
                //显示数据列表
                MotoCommon.MotoReaderAction.turnOffBacklight();
            }
        }
    }
}